package com.yiwei.zhh.impl;

import android.content.Context;

import com.yiwei.zhh.constant.Const;
import com.yiwei.zhh.http.CallBackListener;
import com.yiwei.zhh.http.InterfaceServer;
import com.yiwei.zhh.interfaces.CallRecordInfo;
import com.yiwei.zhh.http.InfoCallBack;
import com.yiwei.zhh.model.CallRecordModel;
import com.yiwei.zhh.model.PhonePwdModel;
import com.yiwei.zhh.model.RequestModel;

import java.util.HashMap;

/**
 * 通话记录
 */
public class CallRecordInfoImpl implements CallRecordInfo {
    private static final int TIME_OUT = 60000;

    public void getCallRecordInfo(Context paramContext, String deal_id, String password, String verify_code, String api, final InfoCallBack callBack) {
        HashMap localHashMap = new HashMap();
        localHashMap.put("deal_id", deal_id);
        localHashMap.put("password", password);
        localHashMap.put("verify_code", verify_code);
        RequestModel model = new RequestModel(localHashMap);

        InterfaceServer.getInstance(paramContext.getApplicationContext()).requestInterface(Const.SERVER_API_URL + api, Const.RequestMethod.POST, model, TIME_OUT,new CallBackListener<CallRecordModel>(CallRecordModel.class,callBack));
//                new ResponseListener() {
//            public void onFinishInMainThread(Object object) {
//            }
//
//            public void onStartInMainThread(Object object) {
//                callBack.onFailure(object.toString());
//            }
//
//            @Override
//            public void onSuccessInMainThread(int paramAnonymousInt, String paramAnonymousString, Object result) {
//                try {
//                    CallRecordModel model = (CallRecordModel) result;
//                    if (model.getStatus() == 1)
//                        callBack.onSuccess(model.getMsg());
//                    else if (model.getStatus() == 0) callBack.onFailure(model.getMsg());
//                    //返回数据接口
//                } catch (Exception e) {
//                    e.printStackTrace();
//                }
//            }
//
//            @Override
//            public Object onSuccessInRequestThread(int statusCode, String content) {
//                try {
//                    return JsonUtil.<CallRecordModel>fromJson(content, CallRecordModel.class);
//                } catch (Exception e) {
//                    return null;
//                }
//            }
//        });
    }

    public void getCaptchaInfo(Context mContext, String paramString, final InfoCallBack callBack) {
        RequestModel model = new RequestModel(new HashMap());
        InterfaceServer.getInstance(mContext.getApplicationContext()).requestInterface(Const.SERVER_API_URL + paramString, Const.RequestMethod.POST, model, Const.DEFAULT_TIMEOUT, new CallBackListener<CallRecordModel>(CallRecordModel.class,callBack));
//                new ResponseListener() {
//            public void onFinishInMainThread(Object paramAnonymousObject) {
//            }
//
//            public void onStartInMainThread(Object paramAnonymousObject) {
//                callBack.onFailure(paramAnonymousObject.toString());
//            }
//
//            @Override
//            public void onSuccessInMainThread(int paramAnonymousInt, String paramAnonymousString, Object result) {
//                try {
//                    CallRecordModel model = (CallRecordModel) result;
//                    if (model.getStatus() == 1)
//                        callBack.onSuccess(model);
//                    else callBack.onFailure(model.getMsg());
//                    //返回数据接口
//                } catch (Exception e) {
//                    e.printStackTrace();
//                }
//            }
//
//            @Override
//            public Object onSuccessInRequestThread(int statusCode, String content) {
//                try {
//                    return JsonUtil.<CallRecordModel>fromJson(content, CallRecordModel.class);
//                } catch (Exception e) {
//                    return null;
//                }
//            }
//        });
    }


    public void getPhoneInfo(Context mContext, String deal_id, String password, String verify_code, String customer_password, String round_robin, final InfoCallBack callBack) {
        HashMap map = new HashMap();
        map.put("deal_id", deal_id);
        map.put("password", password);
        map.put("verify_code", verify_code);
        map.put("customer_password", customer_password);
        map.put("round_robin", round_robin);
        RequestModel model = new RequestModel(map);

        InterfaceServer.getInstance(mContext.getApplicationContext()).requestInterface(Const.PHONE, Const.RequestMethod.POST, model, TIME_OUT,new CallBackListener<CallRecordModel>(CallRecordModel.class,callBack));
//                new ResponseListener() {
//            public void onFinishInMainThread(Object paramAnonymousObject) {
//                callBack.onFailure("");
//            }
//
//            public void onStartInMainThread(Object paramAnonymousObject) {
//                callBack.onFailure(paramAnonymousObject.toString());
//            }
//
//            @Override
//            public void onSuccessInMainThread(int paramAnonymousInt, String paramAnonymousString, Object result) {
//                try {
//                    CallRecordModel model = (CallRecordModel) result;
//                    callBack.onSuccess(model);
//                    //返回数据接口
//                } catch (Exception e) {
//                    e.printStackTrace();
//                }
//            }
//
//            @Override
//            public Object onSuccessInRequestThread(int statusCode, String content) {
//                try {
//                    return JsonUtil.<CallRecordModel>fromJson(content, CallRecordModel.class);
//                } catch (Exception e) {
//                    return null;
//                }
//            }
//        });
    }

    public void getSendCodeInfo(Context mContext, String api, final InfoCallBack callBack) {
        RequestModel model = new RequestModel(new HashMap());
        InterfaceServer.getInstance(mContext.getApplicationContext()).requestInterface(Const.SERVER_API_URL + api, Const.RequestMethod.POST, model, Const.DEFAULT_TIMEOUT,new CallBackListener<CallRecordModel>(CallRecordModel.class,callBack));
//                new ResponseListener() {
//            public void onFinishInMainThread(Object paramAnonymousObject) {
//            }
//
//            public void onStartInMainThread(Object paramAnonymousObject) {
//                callBack.onFailure(paramAnonymousObject.toString());
//            }
//
//            @Override
//            public void onSuccessInMainThread(int paramAnonymousInt, String paramAnonymousString, Object result) {
//                try {
//                    CallRecordModel model = (CallRecordModel) result;
//                    if (model.getStatus() == 1)
//                        callBack.onSuccess(model.getMsg());
//                    else callBack.onFailure(model.getMsg());
//                    //返回数据接口
//                } catch (Exception e) {
//                    e.printStackTrace();
//                }
//            }
//
//            @Override
//            public Object onSuccessInRequestThread(int statusCode, String content) {
//                try {
//                    return JsonUtil.<CallRecordModel>fromJson(content, CallRecordModel.class);
//                } catch (Exception e) {
//                    return null;
//                }
//            }
//        });
    }

    @Override
    public void getForgetPhonePwdInfo(Context mContext, final InfoCallBack callBack) {
        RequestModel model = new RequestModel(new HashMap());
        InterfaceServer.getInstance(mContext.getApplicationContext()).requestInterface(Const.FORGET_PHONE_PWD, Const.RequestMethod.GET, model, Const.DEFAULT_TIMEOUT, new CallBackListener<PhonePwdModel>(PhonePwdModel.class,callBack));
//                new ResponseListener() {
//            public void onFinishInMainThread(Object paramAnonymousObject) {
//            }
//
//            public void onStartInMainThread(Object paramAnonymousObject) {
//                callBack.onFailure(paramAnonymousObject.toString());
//            }
//
//            @Override
//            public void onSuccessInMainThread(int paramAnonymousInt, String paramAnonymousString, Object result) {
//                try {
//                    PhonePwdModel model = (PhonePwdModel) result;
//                    callBack.onSuccess(model);
//                } catch (Exception e) {
//                    e.printStackTrace();
//                }
//            }
//
//            @Override
//            public Object onSuccessInRequestThread(int statusCode, String content) {
//                try {
//                    return JsonUtil.<PhonePwdModel>fromJson(content, PhonePwdModel.class);
//                } catch (Exception e) {
//                    return null;
//                }
//            }
//        });
    }
}
